const app = getApp();
  
export const uploadFile = ({
  filePath,
  formData
})=> {

  wx.showLoading({
    title: '加载中',
  })

  return new Promise((resolve, reject) => {
    wx.uploadFile({
      url: app.globalData.url + '/daily/photo/photo/upload', 
      filePath: filePath,
      name: 'file',
      header:{"openId":app.globalData.openId},
      formData:formData,
      success: res =>{ //上传成功
        wx.hideLoading();
        resolve(res.data);
      },
      fail:res =>{
        wx.hideLoading();
        wx.showToast({
          icon: "error",
          title: "网络繁忙，请稍后",
          duration: 1000,
          mask: true
        });
        reject(res);
      }
    })
  })}

 